package com.qs.education.controller;

import org.apache.log4j.Logger;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.qs.education.bean.api.PageBean;
import com.qs.education.bean.beans.EducationGroupResponse;
import com.qs.education.service.IGroupService;

/**
 * 
 * @class GroupController
 * @author Jason
 * @description
 * @date Nov 14, 2018 3:34:05 PM
 */
@Controller
public class GroupController {

	@Autowired
	private IGroupService iGroupService;
	
	private final Logger log = Logger.getLogger(this.getClass());
	
	/**
	 * @Description 查询所有符合条件的群组
	 * @author Jason
	 * @date Nov 20, 2018
	 * @param schoolName
	 * @param currentPage
	 * @param pageSize
	 * @return
	 */
	@RequiresPermissions(value={"user:view"})
	@RequestMapping("/getGroup")
	public ModelAndView getGroupList(String schoolName,
			@RequestParam(defaultValue="1",value="currentPage") Integer currentPage,
			@RequestParam(defaultValue="10",value="pageSize") Integer pageSize){
		
		log.info("后台管理-->查询所有符合条件的群组");
		ModelAndView mv=new ModelAndView("group/list");
		PageBean groupPageBean=  iGroupService.getGroupList(schoolName,currentPage,pageSize);
		mv.addObject("groupPageBean", groupPageBean);
		mv.addObject("schoolName", schoolName);
		
		return mv;
	}
	
	
	/**
	 * @Description 查看群组详细信息
	 * @author Jason
	 * @date Nov 15, 2018
	 * @return
	 */
	@RequiresPermissions(value={"user:view"})
	@RequestMapping("/groupDetailHTML")
	public ModelAndView groupDetailHTML(Long groupId){
		
		log.info("后台管理-->查看群组详细信息");
		ModelAndView mv=new ModelAndView("group/detail");
		EducationGroupResponse educationGroupResponse =  iGroupService.findGroup(groupId);
		mv.addObject("educationGroupResponse", educationGroupResponse);
		
		return mv;
	}
}
